<template>
	<view class="page">
		<view class="form-content">
			<u-form :model="formData" ref="uForm" class="uForm" label-position="top">
				<u-form-item prop="needamount" label="贷款金额（万元）" label-width="auto">
					<u-input v-model="formData.amount" type="string" placeholder="请输入贷款金额" />
					<view slot="right">万元</view>
				</u-form-item>
				<u-form-item prop="needamount" label="贷款期限" label-width="auto">
					<u-input v-model="formData.term" type="number" placeholder="请输入贷款期限" />
					<view slot="right">期</view>
				</u-form-item>
				<u-form-item prop="needamount" label="利率" label-width="auto">
					<u-input v-model="formData.rate" type="string" placeholder="请输入利率" />
					<view slot="right">%</view>
				</u-form-item>
				<u-form-item prop="needdate" label="担保方式" label-width="auto">
					<u-input v-model="formData.method" type="string" placeholder="请输入担保方式" />
				</u-form-item>
				<u-form-item prop="needdesc" label="产品详情 " label-width="auto">
					<u-input type="textarea" v-model="formData.detail" placeholder="请输入产品详情" />
				</u-form-item>
			</u-form>
		</view>
		<view class="save-bottom">
			<view class="fixed-btn save-padding">
				<u-button type="primary" shape="circle" @click="onSubmit">确定</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import dateTime from '@/components/dateTime/dateTime.vue'

	import jnpf from '@/common/js/jnpf.js'
	export default {
		components: {
			dateTime
		},
		name: 'customerBase',
		data() {
			return {
				formData: {
					amount: undefined,
					term: undefined,
					rate: undefined,
					method: undefined,
					detail: undefined,
					number: 1,
					customerId: undefined,
					bankUserId: undefined,
					customerNeedId: undefined,
					customerNeedRecordId: undefined,
				}
			}
		},
		onLoad(options) {
			if (options.customerId) {
				this.formData.customerId = options.customerId;
			}
			if (options.recordId) {
				this.formData.customerNeedRecordId = options.recordId;
			}
			if (options.needId) {
				this.formData.customerNeedId = options.needId;
			}
			if (options.bankUserId) {
				this.formData.bankUserId = options.bankUserId;
			}
		},
		methods: {
			/* 表单提交 */
			onSubmit() {
				uni.showLoading({
					mask: true
				})
				this.$helper.ajax({
					url: "/api/Jiushi/Customerloan",
					method: "POST",
					contentType: "application/json",
					data: this.formData,
					success: res => {
						uni.hideLoading()
						this.$helper.msg(res.data.msg, 'success');
						uni.navigateTo({
							url: '/pagesJiushi/demand/subpage/myloanlist'
						})
					}
				});
			},
		}
	}
</script>

<style>

</style>